package com.jketing;

import java.util.Properties;
import org.springframework.core.io.ClassPathResource;

/**
 * Config 常量定义
 * 
 * @author  李荣华
 * @version v1.0
 * @date    2017-10-29
 * @Spring   4.3.8
 */
public class Config {
	static Properties property = new Properties();
	static {
		try {
			//加载系统配置文件
			ClassPathResource resource = new ClassPathResource("config.properties");
			property.load(resource.getInputStream());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public static String getPropertyByKey(String key) {
		return property.getProperty(key);
	}
	
	/**
	 * getPageSize 获取系统默认分页大小
	 */
	public static int getPageSize(){
		int pageSize = 20;
		try {
			String page = property.getProperty("default.pageSize");
			if(page != null)
				pageSize = Integer.parseInt(page.toString());
		} catch (Exception e) {}
		return pageSize;
	}
}
